package com.puccampinas.finalproject.core.persistence.abstracts;

import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;

import com.puccampinas.finalproject.core.persistence.dao.sqlserver.MySQLUserDAO;
import com.puccampinas.finalproject.core.persistence.entity.Client;
import com.puccampinas.finalproject.core.persistence.entity.Message;
import com.puccampinas.finalproject.core.persistence.entity.Partner;

public abstract class UserDAO extends AbstractDAO<Client>{
	
	protected static UserDAO instance;
	
	protected static String[] queryListInsert = {
			"INSERT INTO wp_usermeta ( user_id, meta_key, meta_value ) VALUES(?,'wp_capabilities', 'a:1:{s:13:\"administrator\";b:1;}')"
			,"INSERT INTO wp_usermeta ( user_id, meta_key, meta_value ) VALUES(?,'wp_user_level', '10')"
			,"INSERT INTO wp_usermeta ( user_id, meta_key, meta_value ) VALUES(?,'first_name', ?)"
			,"INSERT INTO wp_usermeta ( user_id, meta_key, meta_value ) VALUES(?,'nickname', ?)"
			,"INSERT INTO wp_usermeta ( user_id, meta_key, meta_value ) VALUES(?,'rich_editing', 'true')"
			,"INSERT INTO wp_usermeta ( user_id, meta_key, meta_value ) VALUES(?,'comment_shortcuts', 'false')"
			,"INSERT INTO wp_usermeta ( user_id, meta_key, meta_value ) VALUES(?,'admin_color', 'fresh')"
			,"INSERT INTO wp_usermeta ( user_id, meta_key, meta_value ) VALUES(?,'use_ssl', '0')"
			,"INSERT INTO wp_usermeta ( user_id, meta_key, meta_value ) VALUES(?,'show_admin_bar_front', 'true')" };
	
	protected static List<String> listInsert = Arrays.asList(queryListInsert);
	
	public static synchronized UserDAO getDAO() {
		if (instance == null) {
			instance = new MySQLUserDAO();
		}

		return instance;
		
	}
	
	public abstract void insert(final Client user);
	public abstract void update(final Client user);
	public abstract void enable(final Client user);
	public abstract void disable(final Client user);
	public abstract Client find(final Client user);
	public abstract List<Client> find();
	public abstract List<Partner> findAll();
	public abstract List<Partner> findAll(String userEmail);
	public abstract Boolean acompanhar(Long userId, Long partnerId) throws SQLException;
	public abstract Boolean desacompanhar(Long userId, Long partnerId) throws SQLException;
	public abstract Boolean salvarCoordenada(Long userId, String latitude, String longitude) throws SQLException;
	public abstract List<Message> obterMensagens(Long userId);
}
